#include <cstdio>
#include <algorithm>

using namespace std;

struct INT
{
    int l;
};

bool operator < ( INT a, INT b )
{
    return a.l > b.l;
}

int main( )
{
    int i, n, l, sum;
    INT a[ 600 ];
    while ( scanf("%d%d", &l, &n) != EOF )
    {
        for ( i = 0; i < n; i++ )
            scanf("%d", &a[ i ].l);
        sort( a, a + n );
        sum = 0;
        for ( i = 0; i < n; i++ )
        {
            sum += a[ i ].l;
            if ( sum >= l )
                break;
        }
        if ( i == n )
            puts("impossible");
        else
            printf("%d\n", i + 1);
    }
    return 0;
}
